#include <iostream>
using namespace std;
/**
 * @brief stack is a data structure that 满足(satisfied) LIFO.
 * the basic method of stack include init() destroy()
 * push()[push in stack] pop() [pop the top data]
 * get_top()[show top data of a stack] empty()[to 判断(judge) stack
 * 是否为(is it) empty.] the STL head of stack is <stack>.
 * in this file we will 实现(realize) a stack called sequence stack
 * which not a linked stack.All methods' time complexity is O(1).
 * @date May/3/2025
 * @author Annypst
 */

#define MAXSIZE 10
typedef struct
{
    int data[10];
    int top;

} sqstack;

// init
int init(sqstack &s)
{
    s.top = -1;
    cout << "init success!\n";
    return 0;
}

// is_empty
int is_empty(sqstack &s)
{
    if (s.top == -1)
    {
        cout << "empty!\n";
        return 1;
    }
    cout << "isn't empty!\n";
    return 0;
}

// destory
int destory(sqstack &s)
{
    free(&s);
    cout << "destory success!\n";
    return 1;
}

// push
int push(sqstack &s, int e)
{
    if (s.top != MAXSIZE - 1)
    {
        s.data[++s.top] = e;
        cout << "push success!\n";
        return 1;
    }
    else
    {
        cout << "stack full!";
        return 0;
    }
}

// pop
int pop(sqstack &s)
{
    if(s.top!=-1){
        cout << s.data[s.top--] << " pop success!\n";
        return 1;
    }
    else{
        cout<<"stack is empty!\n";
        return 0;
    }
}

//show_top
void show_top(sqstack &s){
    if(s.top!=-1){
        cout<<"top data is "<<s.data[s.top]<<"\n";
        return;
    }
    else{
        cout<<"stack empty!\n";
        return;
    }
}
int main()
{
    sqstack s;
    init(s);
    for(int i=0;i<5;i++){
        int x;
        cin>>x;
        push(s,x);
    }
    show_top(s);
    pop(s);
    show_top(s);
    
    return 0;
}